/*
 * Copyright 2008,2009,2010 Daniel Freitas
 *
 * This file is part of DMF Generic DAO.
 *
 * DMF Generic DAO is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
 * Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * DMF Generic DAO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with DMF Generic DAO. If not, see
 * <http://www.gnu.org/licenses/>.
 */
package com.googlecode.dmf.genericdao.test.dao.sample;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.dmf.genericdao.GenericDao;
import com.googlecode.dmf.genericdao.annotaions.Dao;
import com.googlecode.dmf.genericdao.annotaions.NamedParam;
import com.googlecode.dmf.genericdao.annotaions.QueryMethod;
import com.googlecode.dmf.genericdao.test.PersistentDummy;

/**
 * A sample dao to test for basic GenericDao functionality.
 * <p/>
 * This interface extends several other interfaces, generic and non-generic, so it is possible to test that multiple
 * interface inheritance does not affect the dao proxies.
 *
 * @author <a href="mailto:daniel.mfreitas@gmail.com">Daniel Freitas</a>
 *
 */
@Dao
public interface PersistentDummyDao extends List<PersistentDummy>, GenericDao<PersistentDummy>, Serializable {

    /**
     * Behaves exactly as {@link GenericDao#findAll()} but uses a named query to fetch the data.
     *
     * @return A list will all persisted dummies.
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    @QueryMethod("listEverything")
    public List<PersistentDummy> listEverything();

    /**
     * Finds a dummy by it's first name.
     *
     * @param name
     *            The name to search for.
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    @QueryMethod("findByFirstName")
    public List<PersistentDummy> findByFirstName(@NamedParam("name") String name);

    /**
     * Tests parameters annotated with annotations other than {@link NamedParam}.
     *
     * @param name
     *            Sample parameter.
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    @QueryMethod("namedParamAnnotationMissing")
    public List<PersistentDummy> namedParamAnnotationMissing(@Qualifier("name") String name);

    /**
     * Non annotated parameter list for testing purposes. Finds dummy by last name.
     *
     * @param name
     *            The last name to search for.
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    @QueryMethod("findByLastName")
    public List<PersistentDummy> findByLastName(String name);

    /**
     * Non existing query for testing purposes.
     *
     * @param someText
     *            Sample property.
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    @QueryMethod("findByQueryThatDoesNotExist")
    public List<PersistentDummy> findByQueryThatDoesNotExist(String someText);

    /**
     * Non annotated method for testing purposes.
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    public List<PersistentDummy> nonAnnotatedMethodFindByAge(@NamedParam("age") int age);

    /**
     * Finds a single entity by first name.
     *
     * @param name
     *            The dummy's first name.
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
    @QueryMethod("findSingleByFirstName")
    public PersistentDummy findSingleByFirstName(@NamedParam("firstName") String name);
}
